<%@ page import="main_com.pojo.LookFriendBean" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%--<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>--%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通讯录管理系统-lookFriend.jsp</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        /* 样式设置 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }

        .container {
            width: 80%;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            color: #333;
        }

        .nav-links {
            text-align: center;
            margin: 20px 0;
        }

        .nav-links a {
            margin: 0 15px;
            text-decoration: none;
            color: #007bff;
            font-size: 16px;
        }

        .nav-links a:hover {
            text-decoration: underline;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }

        th, td {
            padding: 10px;
            text-align: left;
            border: 1px solid #ddd;
        }

        th {
            background-color: #f8f9fa;
        }

        .no-contacts {
            text-align: center;
            color: #888;
        }

        .pagination {
            text-align: center;
            margin-top: 20px;
        }

        .pagination a {
            margin: 0 5px;
            padding: 8px 15px;
            text-decoration: none;
            color: #007bff;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        .pagination a.active {
            background-color: #007bff;
            color: white;
        }

        .pagination a:hover {
            background-color: #ddd;
        }

        .footer {
            text-align: center;
            margin-top: 30px;
            color: #888;
        }

        .footer a {
            color: #007bff;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>查看通讯录</h1>

    <!-- Navigation links -->
    <div class="nav-links">
        <a href="http://localhost/friendManager/addFriend.jsp">增加联系人</a>
        <a href="http://localhost/friendManager/updateFriend.jsp">修改联系人</a>
        <a href="http://localhost/friendManager/deleteFriend.jsp">删除联系人</a>
    </div>

    <!-- Contacts table -->
    <table>
        <thead>
        <tr>
            <th>用户姓名</th>
            <th>用户电话</th>
            <th>邮箱地址</th>
            <th>工作单位</th>
            <th>家庭住址</th>
            <th>用户QQ</th>
        </tr>
        </thead>
        <tbody>
        <%
            ArrayList<LookFriendBean> friendslist = (ArrayList<LookFriendBean>) session.getAttribute("friendslist");
            if (friendslist == null || friendslist.isEmpty()) {
        %>
        <tr>
            <td colspan="6" class="no-contacts">您还没有任何联系人！</td>
        </tr>
        <%
        } else {
            for (LookFriendBean ff : friendslist) {
        %>
        <tr>
            <td><%= ff.getName() %>
            </td>
            <td><%= ff.getPhone() %>
            </td>
            <td><%= ff.getEmail() %>
            </td>
            <td><%= ff.getWorkPlace() %>
            </td>
            <td><%= ff.getPlace() %>
            </td>
            <td><%= ff.getQQ() %>
            </td>
        </tr>
        <%
                }
            }
        %>
        </tbody>
    </table>

    <!-- Pagination -->
    <div class="pagination">
        <%
            int currentPage = (Integer) session.getAttribute("currentPage");
            int totalPages = (Integer) session.getAttribute("totalPages");

            // 上一页
            if (currentPage > 1) {
        %>
        <a href="http://localhost/LookFriendController/lookFriend?page=<%= currentPage - 1 %>">&laquo; 上一页</a>
        <%
            }

            // 页码
            for (int i = 1; i <= totalPages; i++) {
        %>
        <a href="http://localhost/LookFriendController/lookFriend?page=<%= i %>"
           class="<%= (i == currentPage) ? "active" : "" %>"><%= i %>
        </a>
        <%
            }

            // 下一页
            if (currentPage < totalPages) {
        %>
        <a href="http://localhost/LookFriendController/lookFriend?page=<%= currentPage + 1 %>">下一页 &raquo;</a>
        <%
            }
        %>
    </div>

    <div class="footer">
        <p>© 2024 个人信息管理系统 | <a href="http://localhost/lookMessage/lookMessage.jsp">返回首页</a></p>
    </div>
</div>
</body>
</html>
